#ifndef DYNAMICVALUE_H
#define DYNAMICVALUE_H

#include "stdlib.h"

//This class allows for a float to be stored
//and altered according to a movement function
//good for creating moving objects

//NOTE:
//  increase mass to decrease speed, but will take longer to reach finish point
//  increase attraction to get object there faster, but will be a bit jerky
//  increase damping to add bounce
class DynamicValue
{
public:
    DynamicValue(float value = 0.0);

    float value; //this holds the current value
    float target; //this holds the targeted value

    void setTarget(float target); //here you can set a target for the dynamic value
    void setValue(float value);//here you can over-ride the targeting and set a value

    void update();

    //damping and attraction alter the movement patterns
    void setDamping( float d );
    void setAttraction( float a );

    //set the floor, ceiling and target stop threshold
    void setFloor( float f );
    void setCeiling( float c);
    void setTargetStopThreshold( float t);

    bool isTargeting();

private:
    //variables that control the change in the value
    float damping;
    float attraction;
    float mass;

    float velocity;
    float acceleration;
    float force;

    bool targeting; //stores whether presently targeting a new value

    //use these so item won't bounce out of bounds
    float floor;//lowest value permitted to element
    float ceiling;//highest value permitted to element

    float targetStopThreshold;//what distance between target and value is permitted - so doesn't target forever

};


#endif // DYNAMICVALUE_H
